/*******************************************************************************
Project : Master Project — Generating input files
Authors : Briones L., Chiseliov V., Gushchin E., Narayanaswamy G.
Purpose : Construct Data; merge with AIDIS waves; then build tables/figures
Date    : 09 Feb 2026
*******************************************************************************/

version 16
clear all
set more off
set varabbrev off

*==============================================================================
* 0. PROJECT ROOT + RUN TOGGLES
*==============================================================================

* --- Set project root (edit once) ---
global PROJROOT "C:\Users\akank\OneDrive\Desktop\Replication Package-Bank_Expansion_and_ML_Interest_Rates"
cd "$PROJROOT"

* --- Run toggles ---
local RUN_INPUTFILES  1
local RUN_NSS_WAVES   1
local RUN_TABLES      1
local RUN_FIGURES     1	

*==============================================================================
* 1. INPUT FILES: MOF + CENSUS + MAPPING FILES
*==============================================================================

if `RUN_INPUTFILES' {

    di as txt ">>> Building MOF/Census inputs + mapping files..."

    * Processing Census 2001
    do "Data\MOF_Data\Census 2001\Census_2001.do"

    * Merging Census with RBI treatment (Underbanked list)
    do "Data\MOF_Data\Census 2001\treatment.do"

    * Processing RBI 2005 Q1 data
    do "Data\MOF_Data\RBI_2005_Q1\2005 Q1 Compilation.do"

    * Creating mapping files between Census–UB list–2005 Q1 and NSS rounds
    do "Do-files\NSS_59_Merging.do"
    do "Do-files\NSS_70_Merging.do"
    do "Do-files\NSS_77_Merging.do"
}

*==============================================================================
* 2. NSS / AIDIS WAVES: BUILD ANALYSIS DATASETS
*==============================================================================

if `RUN_NSS_WAVES' {

    di as txt "... Build NSS Waves..."
	do "Do-files\Build_NSS_Waves"
}


*==============================================================================
* 3. TABLES
*==============================================================================

if `RUN_TABLES' {
    di as txt ">>> Generating tables..."
    do "Do-files\All Tables.do"
}


*==============================================================================
* 4. FIGURES
*==============================================================================

if `RUN_FIGURES' {
	cd ..
    di as txt ">>> Generating figures..."
    do "Do-files\All Figures.do"
}

di as result ">>> DONE."
